﻿using AllInOne.Classes;
using HY.Common;
using PropertyChanged;
using System.Windows;
using System.Windows.Controls;

namespace AllInOne.Controls
{
    /// <summary>
    /// SetLocal.xaml 的交互逻辑
    /// </summary>
    [AddINotifyPropertyChangedInterface]
    public partial class SetFaKaJi : UserControl
    {
        public SetFaKaJi()
        {
            InitializeComponent();
            DataContext = this;
        }

        public string SendSerialPortName { get; set; } = INIHelper.Read("ALL", "SendSerialPortName");

        public int SendBaudRate { get; set; } = SystemParam.SendBaudRate;

        public int CountDownReadCard { get; set; } = SystemParam.CountDownReadCard;
        public int CountDownReadQR_Code { get; set; } = SystemParam.CountDownReadQR_Code;

        public string HiddenBirthdy { get; set; } = INIHelper.Read("ALL", "HiddenBirthdy");

        
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            SystemParam.SendSerialPortName = SendSerialPortName;
            SystemParam.SendBaudRate = SendBaudRate;
            SystemParam.CountDownReadCard = CountDownReadCard;
            SystemParam.CountDownReadQR_Code = CountDownReadQR_Code;            
            SystemParam.HiddenBirthdy = HiddenBirthdy == "True";

            INIHelper.Write("ALL", "SendSerialPortName", SendSerialPortName);
            INIHelper.Write("ALL", "SendBaudRate", SendBaudRate.ToString());
            INIHelper.Write("ALL", "CountDownReadCard", CountDownReadCard.ToString());
            INIHelper.Write("ALL", "CountDownReadQR_Code", CountDownReadQR_Code.ToString());
            INIHelper.Write("ALL", "HiddenBirthdy", HiddenBirthdy);

            HandyControl.Controls.Growl.Info("保存成功");
        }
    }
}
